const app = getApp()

Page({
  data: {
    activeTab: 'hot',
    services: [
      {
        id: 1,
        gname: '日常保洁',
        price: 199,
        sales: 1000,
        prove: '/static/images/cleaning1.png'
      },
      {
        id: 2,
        gname: '深度保洁',
        price: 299,
        sales: 800,
        prove: '/static/images/cleaning1.png'
      },
      {
        id: 3,
        gname: '除螨服务',
        price: 399,
        sales: 600,
        prove: '/static/images/cleaning1.png'
      }
    ]
  },

  onLoad: function (options) {
    // 使用假数据，不需要请求接口
  },

  // 切换标签
  switchTab(e) {
    const type = e.currentTarget.dataset.type
    this.setData({
      activeTab: type
    })
  },

  // 返回上一页
  goBack() {
    wx.navigateBack()
  },

  // 跳转到详情页
  goToDetail(e) {
    const id = e.currentTarget.dataset.id
    console.log('跳转到详情页，商品ID:', id)
    if (!id) {
      wx.showToast({
        title: '商品信息错误',
        icon: 'none'
      });
      return;
    }
    wx.navigateTo({
      url: `/pages/services/homecare/detail/index?id=${id}`
    })
  }
}) 